#define  _CRT_SECURE_NO_WARNINGS
class Solution {
public:
    vector<int> getAverages(vector<int>& nums, int k) {
        int len = k * 2 + 1;
        int n = nums.size();
        vector<int> ret(n, -1);

        if (k * 2 + 1 > n) return ret;

        long long sum = 0;
        for (int i = 0; i < 2 * k; i++)
        {
            sum += nums[i];
        }

        for (int i = k; i + k < n; i++)
        {
            sum += nums[i + k];
            ret[i] = sum / len;
            sum -= nums[i - k];
        }
        return ret;
    }
};